#ifndef NODE_HPP
#define NODE_HPP
#include <vector>
#include <string>
#include <iostream>
using namespace std;

#define BRODIST 150
#define DADDIST 150
#define NODE_SIZE 64


class Node
{
public :
    enum NodeType
    {
        ABSTRACT,
        USER,
        APPLICATION,
        INTERACTION,

        NB_NODE_TYPE // doit rester en dernier
    };
    enum RelationType
    {
        NONE,
        CHOICE,
        ORDER_INDEPENDANCE,
        INTERLEAVING,
        SYNCHRONIZATION,
        DISABLING,
        SUSPEND_RESUME,
        SEQUENCE,
        SEQUENTIAL_ENABLING_INFO,

        NB_RELATION_TYPE // doit rester en dernier
    };

private :
    friend class Tree;
    Node* _father;
    Node* _rightSibling;
    std::vector<Node*> _children;

    NodeType _type;
    RelationType _relationType;
    std::string _name;
    int _x;
    int _y;
    bool _iterative;
    bool _optional;

    static int cardinal;

public :
    Node();
    Node(const Node& orig);
    ~Node();

    void moveGraphically(int dx, int dy);
    void addChild(Node* newChild);
    void addLeftSibling(Node* newLeftSibling);

    void setName(const std::string& name);
    void setType(NodeType nodeType);
    void setRelationType(RelationType nodeType);
    void setIterative();
    void setOptional();

    int getX() const;
    int getY() const;
    Node* const getFather() const;
    Node* const getRightSibling() const;
    const std::string& getName() const;
    NodeType getType() const;
    RelationType getRelationType() const;
    bool isIterative() const;
    bool isOptional() const;

    const std::vector<Node*>& getChildren() const;
    void getExtremes(int* minX, int* minY, int* maxX, int* maxY) const;

    int redrawSubTree();

    void getNodes(int x, int y);

    void toString(std::ostringstream& s);
    void open(std::ifstream& i);

};

#endif // NODE_HPP
